package h.a.a.i;

import h.a.a.j.c;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Arrays;
import java.util.Objects;
import java.util.concurrent.locks.ReentrantLock;

/* compiled from: IdentityScopeLong */
public class b<T> implements a<Long, T> {
    public final c<Reference<T>> a = new c();
    public final ReentrantLock b = new ReentrantLock();

    public void a(Object obj, Object obj2) {
        this.a.b(((Long) obj).longValue(), new WeakReference(obj2));
    }

    public boolean b(Object obj, Object obj2) {
        Long l = (Long) obj;
        this.b.lock();
        try {
            boolean z;
            if (h(l.longValue()) != obj2 || obj2 == null) {
                z = false;
            } else {
                remove(l);
                z = true;
            }
            this.b.unlock();
            return z;
        } catch (Throwable th) {
            this.b.unlock();
        }
    }

    public void c() {
        this.b.unlock();
    }

    public void clear() {
        this.b.lock();
        try {
            c cVar = this.a;
            cVar.d = 0;
            Arrays.fill(cVar.a, null);
        } finally {
            this.b.unlock();
        }
    }

    public void d(Iterable<Long> iterable) {
        this.b.lock();
        try {
            for (Long longValue : iterable) {
                this.a.c(longValue.longValue());
            }
        } finally {
            this.b.unlock();
        }
    }

    public void e() {
        this.b.lock();
    }

    public Object f(Object obj) {
        Reference reference = (Reference) this.a.a(((Long) obj).longValue());
        return reference != null ? reference.get() : null;
    }

    public void g(int i) {
        c cVar = this.a;
        Objects.requireNonNull(cVar);
        cVar.d((i * 5) / 3);
    }

    public Object get(Object obj) {
        return h(((Long) obj).longValue());
    }

    public T h(long j) {
        this.b.lock();
        try {
            Reference reference = (Reference) this.a.a(j);
            return reference != null ? reference.get() : null;
        } finally {
            this.b.unlock();
        }
    }

    public void i(long j, T t) {
        this.b.lock();
        try {
            this.a.b(j, new WeakReference(t));
        } finally {
            this.b.unlock();
        }
    }

    /* renamed from: j */
    public void remove(Long l) {
        this.b.lock();
        try {
            this.a.c(l.longValue());
        } finally {
            this.b.unlock();
        }
    }

    public void put(Object obj, Object obj2) {
        i(((Long) obj).longValue(), obj2);
    }
}
